package gat.common.enums;

import com.google.common.base.Enums;

import lombok.Getter;

@Getter
public enum TradeTypeEnum {

    VIP_BUY(1, "开通普通会员", MemberTypeEnum.ORDINARY_MEMBER.getCode(), "buy"),

    ;


    private Integer tradeType;

    private String tradeTypeName;

    private String memberType;

    private String operateType;


    private TradeTypeEnum(Integer tradeType, String tradeTypeName, String memberType, String operateType) {
        this.tradeType = tradeType;
        this.tradeTypeName = tradeTypeName;
        this.memberType = memberType;
        this.operateType = operateType;
    }

    public static TradeTypeEnum getByTradeType(Integer tradeType) {
        for (TradeTypeEnum tradeTypeEnum : values()) {
            if (tradeTypeEnum.getTradeType().equals(tradeType)) {
                return tradeTypeEnum;
            }
        }
        return null;
    }

    public static TradeTypeEnum getIfPresent(String name) {
        return Enums.getIfPresent(TradeTypeEnum.class, name).orNull();
    }

    public static TradeTypeEnum getByMenberTypeAndOperateType(String memberType, String operateType) {
        for (TradeTypeEnum tradeTypeEnum : values()) {
            if (tradeTypeEnum.getMemberType().equals(memberType) && tradeTypeEnum.getOperateType().equals(operateType)) {
                return tradeTypeEnum;
            }
        }
        return null;
    }
}
